﻿#ifndef ITEMVIEW_H
#define ITEMVIEW_H

#include "head/g_pch.h"
#include "support/sp_env.h"

#include "m_fhs.h"

#define VT_TEXT 1
#define VT_IMG 2

#define URL_CDN "http://images.qicety.com/"

namespace Ui {
class ItemView;
}

class ItemView : public QDialog
{
    Q_OBJECT

public:
    explicit ItemView(QWidget *parent = 0);
    ~ItemView();

    void replyFinished(QNetworkReply *reply);
    void fileReadyRead();
    void downloadFinish();
    void downloadUrl(const QString &url);

    int getViewType() const;
    bool hasImage() const;
    QImage getImage() const;
    void display(const QString &label,
                 const QString &detail);

protected:
    void mouseDoubleClickEvent(QMouseEvent *event);

private:
    Ui::ItemView *ui;

    QNetworkAccessManager *manager;
    QNetworkReply *downloadReply;
    QString filePath;
    QFile *file;
    bool isFinished;

    QString _title;
    QSize defaultSize;
    QString base_url;
    int viewType;
};

#endif // ITEMVIEW_H
